<?php
/**
 * 列表展开类
 * @copyright   2011 友拓软件友拓通
 * @category   	列表展开类
 * @package  	Action
 * @version 	2011-03-23
 * @author    	黄明兴
 */
class AjaxExpandPublicAction extends CommonAction {
	/// 取产品类别
	public function getProductClassList() { 
		$id	= $_POST['id'];
		$model	= D('ProductClassView');
		$info	= $model->find($id); 
		$class_id 	= intval($id);
		$class_level	= intval($info['class_level']);
		$show_id 		= trim($_POST['show_id']);
		if ($class_id>0) {
///			$this->module_access = $_SESSION['_MODULE_ACCESS_'] = RBAC::getModuleAccessList(USER_ID,'ProductClass');
	  		$list = $model->getExpandProductClassList($class_id,$class_level);
			/// 构造列表展开所需的数据
			$show	= array(
				array('value'=>'class_no','title'=>L('class_no'),'width'=>'40%'),
				array('value'=>'class_name','title'=>L('class_name'),'width'=>'40%')
			);
			$info	= array(
				'show'=>$show,
				'from'=>$list,
			); 
			if (($class_level+1)<C('PRODUCT_CLASS_LEVEL')) {
				$this->assign('expand',true);
				$this->assign('expandAction','getProductClassList');
			}
			$this->assign('table_attr','id="index_expand_'.($class_level+1).'" class="list" border=1');
			$this->assign('tr_attr',array('id'=>'expand_'.($class_level+1)));  
			$this->assign('list',$list['list']);
			$this->display();
		}
	}
	///获取展开城市
	public function getDistrictList(){
		$id 	 = intval($_POST['id']);///国家ID
		$to_hide = intval($_POST['query']['b.to_hide']);
		if ($id > 0 ) {	
///			$this->module_access = $_SESSION['_MODULE_ACCESS_'] = RBAC::getModuleAccessList(USER_ID,'District');	 
			$where	=	'parent_id='.intval($id);
		 	if (!empty($_POST['like']['b.district_name'])) {
		 		$where	.=' and district_name like "%'.$_POST['like']['b.district_name'].'%" ';	
		 	}
		 	if ($to_hide>0) {	
		 		$where	.=' and to_hide='.$to_hide.' '; 	
		 	}
		 	$list	= M('District')->where($where)->group('id')->select();
		 	$list 	= _formatList($list);
		 	$this->assign('list',$list);
		 	$class_level	= 0;
		 	$this->assign('table_attr','id="index_expand_'.($class_level+1).'" class="list" border=1');
			$this->assign('tr_attr',array('id'=>'expand_'.($class_level+1))); 
		 	$this->display();
		}
	}
}